﻿@model Stamp_For_Africa_Version_2.Models.Stamp
@{
	ViewBag.Title = "Create";
}
<h2>
	Create</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jQuery/jquery.ui.datepicker.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.13.min.js")" type="text/javascript"></script>
<script src="@Url.Content("/uploadify/swfobject.js")" type="text/javascript"></script>
<script src="@Url.Content("/uploadify/jquery.uploadify.v2.1.4.min.js")" type="text/javascript"></script>

<link href="@Url.Content("/uploadify/uploadify.css")" rel="stylesheet" type="text/css" />


<script type="text/javascript">


	$(function () {

		// Uploadify File Upload System
		// SessionSync data is sent in scriptData for security reasons, see UploadifySessionSync() in global.asax

		var UploadifyAuthCookie = '@(Request.Cookies[FormsAuthentication.FormsCookieName] == null ? "" : Request.Cookies[FormsAuthentication.FormsCookieName].Value)';
		var UploadifySessionId = '@Session.SessionID';

		$("#fuFileUploader").uploadify({

			'hideButton': true,       // We use a trick below to overlay a fake html upload button with this hidden flash button                         
			'wmode': 'transparent',
			'uploader': '@Url.Content("/uploadify/uploadify.swf")',
			'cancelImg': '@Url.Content("/uploadify/cancel.png")',
			'buttonText': 'Upload File',
			'script': '@Url.Action("FileUpload", "Stamps")',
			'multi': true,
			'auto': true,
			'scriptData': { RequireUploadifySessionSync: true, SecurityToken: UploadifyAuthCookie, SessionId: UploadifySessionId },
			'onComplete': function (event, ID, fileObj, response, data) {
				response = $.parseJSON(response);
				if (response.Status == 'OK') {

					$("#UploadedFileName").val(response.returnFile);
					$("#NonRootedUploadedFileName").val(response.serverPath);
					$("#StampImage").attr("src", response.serverPath);
					// Put your own handler code here instead of the following...
					alert('File Uploaded OK!' + response.serverPath);
				}
			},
			'onError': function (event, queueID, fileObj, errorObj) {
				alert("Error!!! Type: [" + errorObj.type + "] Info [" + errorObj.info + "]");
			}
		});
	});

 </script>


<script type="text/javascript">

	function showDialog() {
		$("#dialogUploadStamp").dialog();
		return false;
	}
</script>

<script type="text/javascript">
  $(document).ready(function () {
    $('.date').datepicker({ dateFormat: "dd/mm/yy" });
  });
</script>

<div style="display: none;" id="dialogUploadStamp" title="Upload Stamp">

		<div style="position: relative;">
        
        <input type="button" id="btnUpload" value="Upload File" />

        <div style="position: absolute; top: 4px; left: 3px;">
            <input id="fuFileUploader" name="file_upload" type="file" />
        </div>
    </div>

</div>

@using (Html.BeginForm())
{
	@Html.ValidationSummary(true)
	
	
	<fieldset>
		<legend>Stamp</legend>

		<p>
		<a href="" onclick="return showDialog()">Select the Stamp Image</a>
		</p>
		<img id="StampImage" src=@Model.NonRootedUploadedFileName alt="" />
		 
		 
			@Html.HiddenFor(model => model.UploadedFileName)
			@Html.HiddenFor(model => model.NonRootedUploadedFileName)
	

		<div class="editor-label">
			@Html.LabelFor(model => model.DisplayName)
		</div>
		<div class="editor-field">
			@Html.EditorFor(model => model.DisplayName)
			@Html.ValidationMessageFor(model => model.DisplayName)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.Country)
		</div>
		<div class="editor-field">
			@Html.DropDownListFor(model => model.CountryId, Model.Countries)
			@Html.ValidationMessageFor(model => model.CountryId)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.FaceValue)
		</div>
		<div class="editor-field">
			@Html.EditorFor(model => model.FaceValue)
			@Html.ValidationMessageFor(model => model.FaceValue)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.CurrentValue)
		</div>
		<div class="editor-field">
			@Html.EditorFor(model => model.CurrentValue)
			@Html.ValidationMessageFor(model => model.CurrentValue)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.CurrencyId)
		</div>
		<div class="editor-field">
			@Html.DropDownListFor(model => model.CurrencyId, Model.Currencies)
			@Html.ValidationMessageFor(model => model.CurrencyId)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.UploaderId)
		</div>
		<div class="editor-field">
			@Html.DropDownListFor(model => model.UploaderId, Model.Uploaders)
			@Html.ValidationMessageFor(model => model.UploaderId)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.PrimaryColorId)
		</div>
		<div class="editor-field">
			@Html.DropDownListFor(model => model.PrimaryColorId, Model.Colours)
			@Html.ValidationMessageFor(model => model.PrimaryColorId)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.MainIdentifier)
		</div>
		<div class="editor-field">
			@Html.EditorFor(model => model.MainIdentifier)
			@Html.ValidationMessageFor(model => model.MainIdentifier)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.SubIdentifier)
		</div>
		<div class="editor-field">
			@Html.EditorFor(model => model.SubIdentifier)
			@Html.ValidationMessageFor(model => model.SubIdentifier)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.FromDate)
		</div>
		<div class="editor-field">
@Html.TextBoxFor( model => model.FromDate, 
                  new { @class = "date" })

			@Html.ValidationMessageFor(model => model.FromDate)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.ToDate)
		</div>
		<div class="editor-field">
@Html.TextBoxFor( model => model.ToDate, 
                  new { @class = "date" })

			@Html.ValidationMessageFor(model => model.ToDate)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.ArtistId)
		</div>
		<div class="editor-field">
			@Html.DropDownListFor(model => model.ArtistId, Model.Artists)
			@Html.ValidationMessageFor(model => model.ArtistId)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.SearchTags1)
		</div>
		<div class="editor-field">
			@Html.EditorFor(model => model.SearchTags1)
			@Html.ValidationMessageFor(model => model.SearchTags1)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.SearchTags2)
		</div>
		<div class="editor-field">
			@Html.EditorFor(model => model.SearchTags2)
			@Html.ValidationMessageFor(model => model.SearchTags2)
		</div>
		<p>
			<input type="submit" value="Create" />
		</p>
	</fieldset>
}
<div>
	@Html.ActionLink("Back to List", "Index")
</div>
